Skip to main content

Environment Variables

Catalyst can be configured through a config/config.json file in the root of your project directory. You can define your keys to access them inside the project.


Loading environment variables on the server

To load environment variables on the server, you need to specify them in the config/config.json file as a JSON object. These variables will be accessible through process.env[variable_name].

Here are the default values for some environment variables:

keydefaultdescription
NODE_SERVER_HOSTNAME"localhost"Change the server hostname while running your application
NODE_SERVER_PORT3005Change the server port while running your application
WEBPACK_DEV_SERVER_HOSTNAME"localhost"It defines application client hostname where your client dev server will be running
WEBPACK_DEV_SERVER_PORT3006It defines application client port where your client dev server will be running
BUILD_OUTPUT_PATHbuildUse this to describe your build folder name or path
PUBLIC_STATIC_ASSET_PATH"/assets/"This key is used to add your path from where you are serving your assets, by default your assets get served from the server. You can change this and add your cdn path to serve assets from there
PUBLIC_STATIC_ASSET_URL"http://localhost:3006"This key is used to change your hostname from where you want your assets to be served.
NODE_ENVdevelopmentDefine your node environment
API_URL""You can use this key to provide API url for your application. We are using this key inside fetch instance which we have provided for api calling
ANALYZE_BUNDLEfalseEnable webpack analyze for bundle information
CLIENT_ENV_KEYS[]Keys which are written inside config.json will not be available to client code. To access them at client, you need to specify them inside this array
ENABLE_DEBUG_LOGSfalseDisable file logs by passing false to this key in config.json
ENABLE_CONSOLE_LOGGINGtrueDisable all types of logs in production or development by passing a boolean

Loading environment variables on the client

Out of the complete contents of config/config.json, keys listed in CLIENT_ENV_KEYS are filtered and made available for the client side code.

Any key that is listed in CLIENT_ENV_KEYS will be exposed on the client and can become a security issue. Be careful while adding keys